import 'package:flutter/material.dart';
import 'package:flutter_hx/pages/account/account_list_view/account_list_view.dart';
import 'package:flutter_hx/services/app_theme_services.dart';
import 'package:flutter_hx/widgets/round_underline_tab_indicator.dart';
import 'package:get/get.dart';

import 'account_logic.dart';

class AccountPage extends GetView<AccountLogic> {
  const AccountPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var type=Get.arguments;
    controller.getAccountInfo(type);
    final title=type==1?"余额":(type==2?"酒呗":"酒票");
    return Scaffold(
      backgroundColor: AppThemeServices.appColors.background,
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        automaticallyImplyLeading: true,
        iconTheme:const IconThemeData(
          color: Colors.black
        ),
        centerTitle: true,
        title: Text(title,style: AppThemeServices.textTheme.appBarTitle),
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 10,vertical: 10),
        child: Column(
          children: [
            Obx(() => Container(
              height: 154,
              width: double.infinity,
              decoration: const BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage("assets/images/balance_account_bg.png"),
                      fit: BoxFit.fill
                  )
              ),
              child: Column(
                children: [
                  const SizedBox(height: 20),
                  Text("可用$title",style: AppThemeServices.textTheme.h14.copyWith(color: Colors.white)),
                  Text("${controller.account.value["balance"]??"0.00"}",style: AppThemeServices.textTheme.h32.bold().copyWith(color: Colors.white,fontSize: 30)),
                  Expanded(child: Row(
                    children: [
                      Expanded(child: Column(
                        mainAxisAlignment:MainAxisAlignment.end,
                        children: [
                          Text("昨日获得",style: AppThemeServices.textTheme.h12.copyWith(color: Colors.white38)),
                          const SizedBox(height: 6),
                          Text("${controller.account.value["yesterday"]??"0.00"}",style: AppThemeServices.textTheme.h20.bold().copyWith(color: Colors.white)),
                        ],
                      )),
                      Expanded(child: Column(
                        mainAxisAlignment:MainAxisAlignment.end,
                        children: [
                          Text("今日获得",style: AppThemeServices.textTheme.h12.copyWith(color: Colors.white38)),
                          const SizedBox(height: 6),
                          Text("${controller.account.value["today"]??"0.00"}",style: AppThemeServices.textTheme.h20.bold().copyWith(color: Colors.white)),
                        ],
                      )),
                      Expanded(child: Column(
                        mainAxisAlignment:MainAxisAlignment.end,
                        children: [
                          Text("累计获得",style: AppThemeServices.textTheme.h12.copyWith(color: Colors.white38)),
                          const SizedBox(height: 6),
                          Text("${controller.account.value["total"]??"0.00"}",style: AppThemeServices.textTheme.h20.bold().copyWith(color: Colors.white)),
                        ],
                      ))
                    ],
                  )),
                  const SizedBox(height: 10)
                ],
              ),
            )),
            const SizedBox(height: 10),
            Expanded(child: Container(
              decoration: BoxDecoration(
                  color:Colors.white,
                  borderRadius: BorderRadius.circular(7.5)
              ),
              child: Column(
                children: [
                  TabBar(
                    indicatorSize: TabBarIndicatorSize.label,
                    indicatorPadding: EdgeInsets.zero,
                    padding: EdgeInsets.zero,
                    labelPadding: const EdgeInsets.symmetric(horizontal: 10,vertical: 0),
                    indicatorColor: AppThemeServices.appColors.colorPrimary,
                    indicatorWeight: 3,
                    indicator: RoundUnderlineTabIndicator(radius: 5, color: AppThemeServices.appColors.colorPrimary, insets:const EdgeInsets.only(left: 17.5,right: 17.5)),
                    labelStyle: AppThemeServices.textTheme.h15.copyWith( fontWeight: FontWeight.w700),
                    unselectedLabelColor:const Color.fromRGBO(153, 153, 153, 1),
                    unselectedLabelStyle: AppThemeServices.textTheme.h15,
                    controller: controller.tabController,
                    labelColor: AppThemeServices.appColors.colorPrimary,
                    tabs:const [
                      Tab(text: "获得明细"),
                      Tab(text: "使用明细",)
                    ],
                  ),
                  Expanded(child: TabBarView(
                    controller: controller.tabController,
                    children: [
                      AccountListView(accountType: type,isConsume: false),
                      AccountListView(accountType: type,isConsume: true),
                    ],
                  ))
                ],
              ),
            ))
          ],
        )
      ),
    );
  }
}
